__author__ = 'vincent LIU'
import getopt

def extract_opt(arg):
	def usage():
		print("")
		print("The usage of nv_statistic for Python,this program is used for netvalue statistic")
		print('-h, --help: help, i.e. print this message')
		print("-s,--starttime:start time of report")
		print("-e,--endtime:end time of report")
		print("-p,--prod:production of netvalue report")
		print("-d,--disk:netvalue file's disk(default:z) it will find in z:/data/windDB/productionX/netValue/")
		print("-o,--output:output location(default: . )")
		print("-t,--type:different number show different format.4:nv_statistic 5:nv_info 6:netvaluebook")

	opt_dict = {
		'start':'19900101',
	    'end':'21000101',
	    'prod':None,
	    'disk':'z',
	    'output':"None",
	    'item':'fundtable',
	    'type':None
	}

	try:
		opts,args = getopt.getopt(arg[1:],'hs:e:p:d:o:i:t:')
	except getopt.GetoptError as err:
		print("Invalid arguments:{0}".format(err))
		usage()
		exit(-1)
	for name,value in opts:
		if name in ('-h','--help'):
			usage()
			exit(0)
		elif name in ('-s','--start'):
			opt_dict["start"]=value
		elif name in ('-e','--end'):
			opt_dict['end']=value
		elif name in ('-d','--disk'):
			opt_dict['disk']=value
		elif name in ('-o','--output'):
			opt_dict['output']=value
		elif name in ('-i','--item'):
			opt_dict['item']=value
		elif name in ('-p','--prod'):
			opt_dict['prod']=value
		elif name in ('-t','--type'):
			opt_dict['type'] = value
	return opt_dict

